﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ThePushCSharp
{
    public class GameState
    {
        public static int MAX_PLAYERS = 6;
        public Renderer renderer;
        public Map map;
        public int startingResource;
        public ThePush push;
        public static Random random;

        public int numberOfPlayers;
        public Player[] players;
        public Player gamePlayer;

        public GameState(ThePush push, int startingResource, int numberOfPlayers)
        {
            random = new Random();
            this.push = push;
            this.startingResource = startingResource;
            map = new Map(50, 50, this);
            renderer = new Renderer(this);

            this.numberOfPlayers = numberOfPlayers;
            players = new Player[numberOfPlayers];
            initializePlayerColors();

            gamePlayer = players[0];
            map.setUnit(new FootSoldier(players[0], this), 2, 5);
        }

        void initializePlayerColors()
        {
            for (int i = 0; i < numberOfPlayers && i < MAX_PLAYERS; i++)
            {
                Color color;
                switch (i)
                {
                    case 0:
                        color = new Color(1.0f, 0.2f, 0.2f);
                        break;
                    case 1:
                        color = new Color(0.2f, 1.0f, 0.2f);
                        break;
                    case 2:
                        color = new Color(0.2f, 0.2f, 1.0f);
                        break;
                    case 3:
                        color = new Color(1.0f, 0.2f, 1.0f);
                        break;
                    case 4:
                        color = new Color(0.2f, 1.0f, 1.0f);
                        break;
                    case 5:
                        color = new Color(1.0f, 1.0f, 0.2f);
                        break;
                    default:
                        color = new Color(1.0f, 1.0f, 1.0f);
                        break;
                }

                players[i] = new Player(this, "Temp", color);
            }
        }
    }
}
